package model

//执行数据迁移 https://studygolang.com/articles/24221?fr=sidebar

func Migration() {
	// 自动迁移模式
	DB.AutoMigrate(&Articles{}, &ArticlesCategory{}, &Standard{},  &Hospital{}, &Users{},
		&ArticleComment{})
	DB.Model(&ArticleComment{}).AddForeignKey("user_id", "mb_users(id)",
		"CASCADE", "CASCADE")
	DB.Model(&ArticleComment{}).AddForeignKey("reply_to_id", "mb_users(id)",
		"CASCADE", "CASCADE")
	DB.Model(&ArticleComment{}).AddForeignKey("article_id", "mb_articles(id)",
		"CASCADE", "CASCADE")
	DB.Model(&ArticleComment{}).AddForeignKey("parent_id", "mb_article_comments(id)",
		"CASCADE", "CASCADE")
	DB.Model(&ArticleComment{}).AddForeignKey("root_id", "mb_article_comments(id)",
		"CASCADE", "CASCADE")
}
